<!-- BEGIN PAGE HEADER-->
<?php $this->load->view('partials/breadcrumb.tpl',  Array('_NO_IOSS_NEW'=>'1'))?>
<!-- END PAGE HEADER-->
<style>
    th,td{
        text-align: center;
    }
    .o-img{
        width: 50px !important;
        height: auto !important;
        border-radius: 50%;
    }
    .o-name{
        margin-left: 5px;
    }
</style>
<!-- BEGIN PAGE CONTENT-->
<script type="text/javascript">
function defConfirm(url){
	if(!confirm("确定要删除吗？")){
		return false;
	}
	window.location.href = url;
	return true;
}
$(document).ready(function(){
	$("#reset").click(function(){
		$("select").val('');
		$("input[type='text']").val('');
	});
});
</script>
<div class="row">
	<div class="col-xs-12">
		<!-- Begin: life time stats -->
		<div class="portlet">
			<?= form_open('', Array('class' => 'form-inline', 'role' => 'form')) ?>
            <?= search_form_input('nick_name', filterValue('nick_name'), '用户昵称', 'class="form-control input-small"'); ?>
			<?= search_form_input('real_name', filterValue('real_name'), '真实姓名', 'class="form-control input-small"'); ?>
			<?= search_form_input('id_num', filterValue('id_num'), '身份证号', 'class="form-control"'); ?>
			<?= search_form_dropdown('status', array('' => '认证状态...')+MUserAuthInfo::getAuthState(), filterValue('status'), '认证状态', 'class="form-control input-small"'); ?>
            <div style="clear:both;height: 13px"></div>
			<?= search_form_input('user_auth_info_number_perpage', filterValue('user_auth_info_number_perpage'), '每页显示条数', 'class="form-control input-small"'); ?>
			<div class="input-group input-large date-picker input-daterange" data-date="" data-date-format="yyyy-mm-dd">
				<input type="text" class="form-control" name="user_auth_info_create_time_begin"
					   value="<?= filterValue('user_auth_info_create_time_begin') ?>" placeholder="认证起始时间" autoComplete="off">
				<span class="input-group-addon">to </span>
				<input type="text" class="form-control" name="user_auth_info_create_time_end"
					   value="<?= filterValue('user_auth_info_create_time_end') ?>" placeholder="认证结束时间" autoComplete="off">
			</div>
			<button type="button" class="btn default" id="reset">重置条件</button>
			<button type="submit" class="btn green about_search">搜索 <i class="fa fa-search"></i></button>
			<?= form_close() ?>
			<div class="portlet-body">
				<div class="row">
					<div class="col-xs-12">
						<div class="table-scrollable">
							<table class="table table-hover table-bordered table-striped">
								<thead>
								<tr>
									<th>ID</th>
									<th>用户ID</th>
									<th>用户信息</th>
									<th>真实姓名</th>
									<th>身份证号</th>
									<th>身份证正面</th>
									<th>身份证背面</th>
									<th>认证状态</th>
									<th>备注</th>
									<th>创建时间</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								<?php foreach ($list as $v) { ?>
								<tr>
									<td><?= $v->id ?></td>
									<td><?= $v->user_id ?></td>
									<td>
                                        <img class="o-img img-rounded" src="<?= $v->avatar ?>" alt="<?= $v->nick_name ?>">
                                        <span class="o-name"><?= $v->nick_name ?></span>
                                    </td>
									<td><?= $v->real_name ?></td>
									<td><?= $v->id_num ?></td>
									<td><img class="img-rounded" style="width: auto;height: 60px;" src="<?= image_url($v->face_idcard) ?>" /></td>
									<td><img class="img-rounded" style="width: auto;height: 60px;" src="<?= image_url($v->back_idcard) ?>" /></td>
									<td><?= MUserAuthInfo::getAuthState($v->status) ?></td>
									<td><?=$v->remark;?></td>
									<td><?= date('Y-m-d H:i:s', $v->create_time) ?></td>
									<td>
										<div class="btn-group btn-group-solid">
											<button data-id="<?= $v->id ?>" class="btn btn-sm purple change-state">
                                                <i class="fa fa-edit"></i> 处理审核
                                            </button>
										</div>
									</td>
								</tr>
								<?php } ?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12 text-right">
						<?= $pagination ?>
					</div>
				</div>
			</div>
		</div>
		<!-- End: life time stats -->
	</div>
</div>

<div class="modal fade confirm-modal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title apply-title">处理审核</h4>
            </div>
            <div class="modal-body">
                <form id="apply_form">
                    <div class="form-group">
                        <label class="control-label">审核状态：</label>
                        <select id="status-select" name="status" class="form-control">
                            <option value="">选择审核结果...</option>
                            <option value="3">审核通过</option>
                            <option value="2">审核不通过</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="apply_num" class="control-label">备注：</label>
                        <textarea name="remark" class="form-control" placeholder="审核意见"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary confirm-submit">确定</button>
            </div>
        </div>
    </div>
</div>

<!-- END PAGE CONTENT-->
<script type="text/javascript">
    var authId;
	$(document).ready(function () {
		$('.img-rounded').zoomify();
	});
	$(".change-state").click(function () {
        $(".confirm-modal").modal('show');
        authId = this.dataset.id;
    })
    $(".confirm-submit").click(function () {
        var remark = $("textarea[name='remark']").val();
        var status = $("#status-select option:selected").val();
        if (!status){
            toastr.error('请选择审核状态','提示');
            return;
        }
        $.ajax({
            url: "<?= site_url('user/user_auth_info/auth_confirm') ?>",
            method: "POST",
            data: {'id': authId, 'remark': remark, 'status': status},
            dataType: "JSON",
            success: function (data) {
                if (data.status){
                    toastr.success(data.msg,'成功');
                    setTimeout(function () {
                        location.reload()
                    },1000)
                }else {
                    toastr.error(data.msg,'失败');
                }
                $(".confirm-modal").modal('hide');
            }
        })
    })
</script>
